<?php
ini_set('max_execution_time', 600);

$name = "ivan";
$email = "neibr@ya.ru";
$category_id = '114';
$metro_id='21';
$phone='89166603943';

$title='hhhh';
$description = 'rgeg';
//$city=
$param='10208';
$parameters='seller_name='.$name.'&'.'email='.$email.'&'.'category_id='.$category_id.'&'.
		'metro_id='.$metro_id.'&'.'phone='.$phone.'&'.'private=1'.'&'.'params[716]='.'10208'.'&location_id=637640';
//'&title='.$nazvanie.'&main_form_submit=Далее';
//var_dump($parameters);die;
function curl_get($host, $referer = null){
	global $parameters;
    $ch = curl_init();
    //$cookie = str_replace('\\', '/', dirname(__FILE__)) . 'cookie.txt';
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_REFERER, $referer);
    curl_setopt($ch, CURLOPT_USERAGENT, "headers 
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; CIBA; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)");
    curl_setopt($ch, CURLOPT_URL, $host);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
    //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    //curl_setopt($ch, CURLOPT_COOKIEJAR,$_SERVER['DOCUMENT_ROOT'].'/cookie.txt');
   
    
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS,$parameters);
    
    //curl_setopt($ch, CURLOPT_COOKIE, "sessid=de3e9274a96c064fa308bedf70710a79.1381710012;u=1o6qdlss.m3jku5.e9kedila7e");
    $html = curl_exec($ch);
      
    echo curl_error($ch);
    curl_close($ch);
    
    return $html;
}
 
$text = urlencode('');

$result = curl_get("http://www.avito.ru/additem/confirm".$text , 'http://www.avito.ru/');
echo "<script>
document.getElementById('fld_title').value = '".$title."';
document.getElementById('fld_description').value = '".$description."';
document.getElementById('form_submit').value = '".'Далее'."';
</script>";

/*$parameters='seller_name='.$name.'&'.'email='.$email.'&'.'category_id='.$category_id.'&'.
		'metro_id='.$metro_id.'&'.'phone='.$phone.'&'.'private=1'.'&'.'params[716]='.'10208'.'&location_id=637640'.
'&title='.$nazvanie.'&main_form_submit=Далее';*/
//$result=curl_get("http://www.avito.ru/additem/confirm".$text , 'http://www.avito.ru/additem');

//echo $result;

?>